<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click="list.push(99)">加一个元素</button>
        <button @click="list.pop()">删一个元素</button>
        <p>{{ list }}</p>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                list: [10, 20, 30]
            },
            watch: {
                
                // vue里就是这么规定的
                // 因为在vue的内部，对push、pop、splice这些方法做了重新包装
                // 所以才能够直接侦听数组，就能侦听到变化
                list () {
                    console.log('数组有变化')
                }
            }
        })
    </script>
</body>

</html>